package com.takanafu.haru.exp{
	import com.takanafu.haru.code.CodeBase;
	import com.takanafu.haru.code.CodeSymbol;
	import com.takanafu.haru.code.UseCallback;
	import com.takanafu.haru.core.CharacterType;
	import com.takanafu.haru.core.GlobalManager;
	
	public class AssignExpression extends BinaryExpression{
		public function AssignExpression(symbol:CodeSymbol,code:CodeBase){
			super(CharacterType.EQUAL,symbol,code);
		}
		
		override public function run():CodeBase{
			var sym:CodeSymbol = left as CodeSymbol;
			right.thread = this.thread;
			var c:CodeBase = right.run();
			var uc:UseCallback = c as UseCallback;
			
			if(uc == null){
				GlobalManager.setSymbol(sym,c);
			}
			return c;
		}
		public function runAfterCallback(c:CodeBase):CodeBase{
			var sym:CodeSymbol = left as CodeSymbol;
			
			GlobalManager.setSymbol(sym,c);
			return c;
		}
	}
}